package ecom.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.UserTransaction;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;


import ecom.beans.*;

public class LogoutServlet extends HttpServlet {

	/**
	 * Serializable class uid.
	 */
	private static final long serialVersionUID = 6893863749912962928L;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		
		HttpSession session = request.getSession(true);
		
		session.invalidate();
		
		response.sendRedirect("/ecom/login.jsp");

	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();

	}

	
	private void displayException(final PrintWriter out, final String errMsg,
			final Exception e) {
		out.println("<p>Exception : " + errMsg);
		out.println("<pre>");
		e.printStackTrace(out);
		out.println("</pre></p>");
	}

}
